<?php
/**
 * Created by PhpStorm.
 * User: alice
 * Date: 2015/12/29
 * Time: 9:18
 */

class Involved_ProductBrandModel extends BaseModel
{
    protected $table = 'product_brand';


    /********************************   APP接口   *****************************/

    public function GetProductBrandById($brand_id)
    {
        return DB::table($this->table)->select('brand_name')->where('brand_id',$brand_id)->first();
    }

    public function GetBrandList()
    {
        return DB::table($this->table)
                ->selectRaw('sc_product_brand.brand_id as id,sc_product_brand.brand_name as name')
                ->get();
    }

    /********************************   PC   *****************************/

    /**
     * 产品品牌列表
     * @author alice
     * @date 2016-1-18
     * @return mixed
     */
    public function ShowGoodsBrandList()
    {
       return DB::table($this->table)->paginate(8);
    }

    /**
     * 产品品牌信息
     * @author alice
     * @date 2016-1-18
     * @return mixed
     */
    public function ShowGoodsBrandInfo($id)
    {
        return DB::table($this->table)->where('brand_id',$id)->first();
    }

    public function GetList($field = array())
    {
        return DB::table($this->table)->select($field)->where('is_show', 0)->first();
    }
    /**
     * 获取产品列表
     * @author fyl
     * @date 2016-04-04
     */
    public function AdminProductBrandList()
    {
        return DB::table($this->table)
            ->selectRaw('sc_product_brand.brand_id, sc_product_brand.brand_name, sc_product_brand.brand_img, sc_product_brand.is_show, sc_product_cate.cate_name as quality ')
            ->leftjoin('product_cate','product_cate.cate_id','=','product_brand.quality')
            ->get();
    }

    /**
     * 根据ID获取产品详情
     * @return mixed
     */
    public function GetProductBrandById1($id)
    {
        return  DB::table($this->table)
            ->where('product_brand.brand_id',$id)
            ->first();
    }


}